$(function(){
	loadType();
	goToPage(1);
});

var loadType=function(){
	$.ajax({
		url : contextPath+ 'user/devicetype/list',
		type : 'POST',
		success : function(list) {
			if(list!=null && list.length>0){
				$("#deviceType").empty();
				var option="<option value ='-1'>设备类型</option>";
				for(var i=0;i<list.length;i++){
					var type = list[i];
					//alert(province);
					option +="<option value='"+type.deviceTypeId+"'>"+type.deviceTypeName+"</option>";
				}
				$("#deviceType").append(option);
			}
		}
	});
};

function goToPage(pageNo){
	var operationType = $('#operationType').val();
	var deviceType = $('#deviceType').val();
	//var companyId = $('#companyId').val();
	var beginTime = $('#beginTime').val();
	var endTime = $('#endTime').val();
	var userName = $('#userName').val();
	$.ajax({
		url : contextPath+ 'user/log/list',
		data : {
			operationType : operationType,
			deviceType:deviceType,
			beginTime:beginTime,
			endTime:endTime,
			userName:userName,
			pageNo:pageNo
		},
		type : 'POST',
		success : function(list) {
			$("#content").empty();
			$(".page").empty();
			if(list!=null && list.totalRecord>0){
				var log = list.records;
				for(var i=0;i<log.length;i++){
					var div = '<div class="pwsj_right_czrz_cont">';
					div += '<ul class="czrz_cont_ul">';
					div += '<li class="number" style="width: 10%">'+(i+1)+'</li>';
					div += '<li class="time" style="width: 25%">'+log[i].createTimeStr+'</li>';
					div += '<li class="username" style="width: 40%">'+log[i].content+'</li>';
					div += '<li class="username" style="width: 24%;border-right:none;">'+log[i].operator.loginName+'</li>';
					div += '</ul>';
					div += '</div>';
					$("#content").append(div);
				}
				pageList(list);
			}
		}
	});
}
